<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="container-div">
		<div class="col-sm-12 search-collapse">
			<form id="operlog-form">
				<div class="select-list">
					<ul>
						<li>
							类别名称：<input type="text" name="behaviorCategory"/>
						</li>

						<li>
							可申请方式：
							<select name="status" th:with="type=${@dict.getSqfs()}" class="form-control m-b-none">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.sqName}" th:value="${dict.sqfsId}"></option>
							</select>
						</li>
						<li class="select-time">
							<label>创建时间： </label>
							<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
							<span>-</span>
							<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>
		<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
			<a class="btn btn-success" onclick="$.operate.add(100)" shiro:hasPermission="integral:pdIntegral:add">
				<i class="fa fa-plus"></i> 添加
			</a>
			<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="integral:pdIntegral:edit">
	            <i class="fa fa-edit"></i> 修改
	        </a>
			<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="integral:pdIntegral:remove">
				<i class="fa fa-remove"></i> 删除
			</a>
		</div>
			
		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
    </div>
    <div th:include="include :: footer"></div>
	<script th:src="@{/ajax/libs/select/select2.js}"></script>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('integral:pdIntegral:edit')}]];
        var removeFlag = [[${@permission.hasPermi('integral:pdIntegral:remove')}]];
        var prefix = ctx + "integral/pdIntegral";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "品德A积分管理",
                columns: [{
		            checkbox: true
		        },
				{
					field : 'behaviorId', 
					title : '行为积分主键',
                    visible: false
				},
                    {
                        formatter: function (value, row, index) {
                            return index+ 1;
                        }
                    },
				{
					field : 'behaviorCategory', 
					title : '类别' 
				},
				{
					field : 'behaviorTitle', 
					title : '行为标题' 
				},
				{
					field : 'deptName',
					title : '部门名称',
					width: 204
				},
				{
					field : 'behaviorContent', 
					title : '行为内容' 
				},
				{
					field : 'shenQingFangShi', 
					title : '申请方式',
                    formatter: function (value, row, index) {
                        switch (value) {
                            case '0': return '每天一次';
                            case '1': return '一周一次';
                            case '2': return '一月一次';
							default: return '无限制';
                        }
                    }
				},
				{
					field : 'typeId', 
					title : '类型' 
				},
				{
					field : 'zuiDuoIntegral', 
					title : '最多奖励' 
				},
				{
					field : 'zuiShaoIntegral', 
					title : '最少奖励积分' 
				},
				{
					field : 'integralFenJi', 
					title : '积分分级' 
				},
				{
					field : 'yiWanChengCiShu', 
					title : '已完成次数' 
				},
				{
					field : 'status',
					title : '使用状态',
					formatter: function (value) {
						switch (value) {
							case 0: return '<span class="badge badge-info">使用中</span>';
							case 1: return '<span class="badge badge-danger">已禁用</span>';
						}
					}
				},
				{
					field : 'createTime', 
					title : '创建时间' 
				},
				{
					field : 'updateTime', 
					title : '修改时间' 
				},
				{
					field : 'remark', 
					title : '备注' 
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.behaviorId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.behaviorId + '\')"><i class="fa fa-edit"></i>审批设置</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.behaviorId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="ty(\'' + row.behaviorId + '\')"><i class="fa fa-remove"></i>停用</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        /** 禁用*/
        function ty(behaviorId) {
            var url = prefix + '/integralTy/' + behaviorId;
            $.modal.open("禁用成功", url, '800', '300');
        }
    </script>
</body>
</html>